package com.zxc.userservice.innerController;

import com.zxc.oj.model.entity.User;
import com.zxc.service.UserFeignClient;
import com.zxc.userservice.service.UserService;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collection;
import java.util.List;

@RestController
@RequestMapping("/inner")
@RequiredArgsConstructor
@Slf4j
public class UserInnerController implements UserFeignClient {
    private final UserService userService;

    /**
     * 根据id集合获取用户
     */
    @Override
    @GetMapping("/get/id")
    public User getById(@RequestParam("id") long id) {
        log.info("id：{}",id);
        return userService.getById(id);
    }

    /**
     * 根据id集合获取用户集合
     */
    @Override
    @GetMapping("/get/ids")
    public List<User> listByIds(@RequestParam("ids") Collection<Long> ids) {
        log.info("ids：{}",ids);
        return userService.listByIds(ids);
    }


}
